package user

import (
	"api/pb/user"
	"context"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetIDByMobileLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetIDByMobileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetIDByMobileLogic {
	return &GetIDByMobileLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetIDByMobileLogic) GetIDByMobile(req *types.MobileRequest) (resp *types.Empty, err error) {
	_, err = l.svcCtx.UserRPC.GetUserByMobile(l.ctx, &user.GetUserByMobileRequest{Mobile: req.Mobile})
	if err != nil {
		return nil, err
	}
	return &types.Empty{}, nil
}
